package com.lnsf.bookstore.system.upload.controller;

import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.common.util.FileUpload;
import com.lnsf.bookstore.system.upload.service.UploadService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/file")
public class UploadController {

	@Autowired
    private UploadService logService;

    /**
     * 上传文件
     */
    @RequestMapping("/upload")
    @ResponseBody
    public Object upload(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        String root =  FileUpload.fileUp(file,"aa",request);
        map.put("url",root);
        return  map;
    }




	
}
